<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            height:2000px;
        }
        .banner{
            /*粘性定位*/
            position: sticky;
            top:10px;/*停在距离顶部10px,至少需要写一个top才能生效*/
            width: 1220px;
            height:150px;
            background-color: #ff8500;
            margin: 120px auto;
        }
    </style>
</head>
<body>
<div class="banner"></div>
</body>
</html>